package com.example.spring_seatreservation.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.spring_seatreservation.entity.ReadingRoom;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ReadingRoomMapper extends BaseMapper<ReadingRoom> {

    @Select("select t.*,l.name as library_name,f.name as floor_name from reading_room t " +
            "left join library l on l.id = t.lib_id " +
            "left join floor f on f.id = t.floor_id")
    List<ReadingRoom> getReadingRoom();

    @Select("select count(1) from seat where r_room_id = #{roomId}")
    int selectSeatByRoomId(Long roomId);

    @Select("select count(1) from reading_room where floor_id=#{floorId}")
    int selectRoomByFloorId(Long floorId);
}
